package com.yanqu.road.server.cmd.activity.xiuxian.cross;

import com.yanqu.road.entity.activity.xiuxian.data.XiuXianUserData;
import com.yanqu.road.logic.bussiness.activity.XiuXianActivityBusiness;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.XiuXianProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.xiuxian.XiuXianModule;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_XIU_XIAN_GET_OTHER_INFO_FROM_CROSS, desc = "跨服查看玩家信息请求")
public class XiuXianGetOtherInfoFromCrossCmd extends AbstractCommand {

    private long getUserId;
    private long getServerId;
    private long otherUserId;
    private Integer activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        XiuXianProto.XiuXianGetOtherInfoFromCrossReqMsg reqMsg = XiuXianProto.XiuXianGetOtherInfoFromCrossReqMsg.parseFrom(packet.getBytes());
        getUserId = reqMsg.getUserId();
        getServerId = reqMsg.getServerId();
        activityId = reqMsg.getActivityId();
        otherUserId = reqMsg.getOtherUserId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        XiuXianUserData userData;
        if (player != null) {
            XiuXianModule xiuXianModule = player.getModule(XiuXianModule.class);
            userData = xiuXianModule.getUserData();
        } else {
            userData = XiuXianActivityBusiness.getXiuXianUserData(activityId, otherUserId);
        }
        if (null == userData) {
            return;
        }
        XiuXianModule.getOtherInfoFromCross(userData, activityId, getUserId, getServerId);

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
